{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {
    "colab": {
     "autoexec": {
      "startup": false,
      "wait_interval": 0
     },
     "base_uri": "https://localhost:8080/",
     "height": 34,
     "output_extras": [
      {
       "item_id": 1
      }
     ]
    },
    "colab_type": "code",
    "executionInfo": {
     "elapsed": 993,
     "status": "ok",
     "timestamp": 1521576760373,
     "user": {
      "displayName": "Malavika Bindhi",
      "photoUrl": "https://lh3.googleusercontent.com/a/default-user=s128",
      "userId": "112270139007359607953"
     },
     "user_tz": 420
    },
    "id": "yXjqd36-4pbi",
    "outputId": "e77f1eab-737c-4e17-c2ca-9fa75855ee4e"
   },
   "outputs": [
    {
     "name": "stderr",
     "output_type": "stream",
     "text": [
      "Using TensorFlow backend.\n"
     ]
    }
   ],
   "source": [
    "import numpy as np\n",
    "import sys\n",
    "import os\n",
    "import tensorflow as tf\n",
    "from keras import optimizers\n",
    "from keras.layers import Input, Add, concatenate\n",
    "from keras.layers.merge import Concatenate\n",
    "from keras.models import Model\n",
    "from keras.layers import Dense, Flatten, Reshape, Dropout\n",
    "from keras.layers import Convolution1D, MaxPooling1D, BatchNormalization\n",
    "from keras.layers import Lambda\n",
    "from keras.utils import np_utils\n",
    "import h5py\n",
    "from matplotlib.pyplot import imshow\n",
    "import glob\n",
    "import math\n",
    "from keras.preprocessing.image import load_img\n",
    "from keras.preprocessing.image import img_to_array\n",
    "from keras.applications.imagenet_utils import decode_predictions\n",
    "from keras import backend as K\n",
    "\n",
    "from keras.models import load_model\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {
    "colab": {
     "autoexec": {
      "startup": false,
      "wait_interval": 0
     },
     "base_uri": "https://localhost:8080/",
     "height": 119,
     "output_extras": [
      {
       "item_id": 4
      }
     ]
    },
    "colab_type": "code",
    "executionInfo": {
     "elapsed": 9094,
     "status": "ok",
     "timestamp": 1521576770183,
     "user": {
      "displayName": "Malavika Bindhi",
      "photoUrl": "https://lh3.googleusercontent.com/a/default-user=s128",
      "userId": "112270139007359607953"
     },
     "user_tz": 420
    },
    "id": "YGKXXpvE7Q2N",
    "outputId": "de24a618-654c-42ad-d07d-bb99df909b02"
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "gpg: keybox '/tmp/tmp16sqxkvv/pubring.gpg' created\n",
      "gpg: /tmp/tmp16sqxkvv/trustdb.gpg: trustdb created\n",
      "gpg: key AD5F235DF639B041: public key \"Launchpad PPA for Alessandro Strada\" imported\n",
      "gpg: Total number processed: 1\n",
      "gpg:               imported: 1\n",
      "Warning: apt-key output should not be parsed (stdout is not a terminal)\n"
     ]
    }
   ],
   "source": [
    "# Install a Drive FUSE wrapper.\n",
    "# https://github.com/astrada/google-drive-ocamlfuse\n",
    "!apt-get install -y -qq software-properties-common python-software-properties module-init-tools\n",
    "!add-apt-repository -y ppa:alessandro-strada/ppa 2>&1 > /dev/null\n",
    "!apt-get update -qq 2>&1 > /dev/null\n",
    "!apt-get -y install -qq google-drive-ocamlfuse fuse"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 0,
   "metadata": {
    "colab": {
     "autoexec": {
      "startup": false,
      "wait_interval": 0
     }
    },
    "colab_type": "code",
    "collapsed": true,
    "id": "zRUMrPMU7U-G"
   },
   "outputs": [],
   "source": [
    "# Generate auth tokens for Colab\n",
    "from google.colab import auth\n",
    "auth.authenticate_user()"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 14,
   "metadata": {
    "colab": {
     "autoexec": {
      "startup": false,
      "wait_interval": 0
     },
     "base_uri": "https://localhost:8080/",
     "height": 34,
     "output_extras": [
      {
       "item_id": 1
      }
     ]
    },
    "colab_type": "code",
    "executionInfo": {
     "elapsed": 45073,
     "status": "ok",
     "timestamp": 1521576174634,
     "user": {
      "displayName": "Malavika Bindhi",
      "photoUrl": "https://lh3.googleusercontent.com/a/default-user=s128",
      "userId": "112270139007359607953"
     },
     "user_tz": 420
    },
    "id": "8dS1FPqzASzP",
    "outputId": "e62e9573-f015-420e-bea1-0f4af29cb0e9"
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "··········\n"
     ]
    }
   ],
   "source": [
    "# Generate creds for the Drive FUSE library.\n",
    "from oauth2client.client import GoogleCredentials\n",
    "creds = GoogleCredentials.get_application_default()\n",
    "import getpass\n",
    "!google-drive-ocamlfuse -headless -id={creds.client_id} -secret={creds.client_secret} < /dev/null 2>&1 | grep URL\n",
    "vcode = getpass.getpass()\n",
    "!echo {vcode} | google-drive-ocamlfuse -headless -id={creds.client_id} -secret={creds.client_secret}"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 0,
   "metadata": {
    "colab": {
     "autoexec": {
      "startup": false,
      "wait_interval": 0
     }
    },
    "colab_type": "code",
    "collapsed": true,
    "id": "8KbaU_fz8gas"
   },
   "outputs": [],
   "source": [
    "!pip install -U -q PyDrive\n",
    "\n",
    "from pydrive.auth import GoogleAuth\n",
    "from pydrive.drive import GoogleDrive\n",
    "from google.colab import auth\n",
    "from oauth2client.client import GoogleCredentials\n",
    "\n",
    "# 1. Authenticate and create the PyDrive client.\n",
    "auth.authenticate_user()\n",
    "gauth = GoogleAuth()\n",
    "gauth.credentials = GoogleCredentials.get_application_default()\n",
    "drive = GoogleDrive(gauth)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "colab": {
     "autoexec": {
      "startup": false,
      "wait_interval": 0
     },
     "base_uri": "https://localhost:8080/",
     "height": 187,
     "output_extras": [
      {
       "item_id": 2
      }
     ]
    },
    "colab_type": "code",
    "collapsed": true,
    "executionInfo": {
     "elapsed": 2815,
     "status": "ok",
     "timestamp": 1521576795703,
     "user": {
      "displayName": "Malavika Bindhi",
      "photoUrl": "https://lh3.googleusercontent.com/a/default-user=s128",
      "userId": "112270139007359607953"
     },
     "user_tz": 420
    },
    "id": "Xnl59Q6CAlFv",
    "outputId": "e80010c3-e3b7-4fa6-d8b0-a40b017b6b72"
   },
   "outputs": [],
   "source": [
    "# Create a directory and mount Google Drive using that directory.\n",
    "!mkdir -p drive\n",
    "!google-drive-ocamlfuse drive\n",
    "\n",
    "print ('Files in Drive:')\n",
    "!ls drive/\n",
    "\n",
    "# Create a file in Drive.\n",
    "!echo \"This newly created file will appear in your Drive file list.\" > drive/created.txt"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 0,
   "metadata": {
    "colab": {
     "autoexec": {
      "startup": false,
      "wait_interval": 0
     }
    },
    "colab_type": "code",
    "collapsed": true,
    "id": "PIU1JB7f7qEC"
   },
   "outputs": [],
   "source": [
    "points =  np.load('drive/Colab Notebooks/train_points.npy')\n",
    "labels = np.load('drive/Colab Notebooks/train_labels.npy')\n",
    "labels = labels.reshape((7481,24))\n",
    "classes = np.load('drive/Colab Notebooks/train_classes.npy')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 14,
   "metadata": {
    "colab": {
     "autoexec": {
      "startup": false,
      "wait_interval": 0
     },
     "base_uri": "https://localhost:8080/",
     "height": 34,
     "output_extras": [
      {
       "item_id": 1
      }
     ]
    },
    "colab_type": "code",
    "executionInfo": {
     "elapsed": 878,
     "status": "ok",
     "timestamp": 1521576837147,
     "user": {
      "displayName": "Malavika Bindhi",
      "photoUrl": "https://lh3.googleusercontent.com/a/default-user=s128",
      "userId": "112270139007359607953"
     },
     "user_tz": 420
    },
    "id": "8_J1q5rB_PO8",
    "outputId": "742ea112-cb86-49f7-e9ed-87a953f0e859"
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "(7481, 2048)\n"
     ]
    }
   ],
   "source": [
    "intermediate_output = np.load('drive/Colab Notebooks/intermediate_output.npy')\n",
    "intermediate_output = np.squeeze(intermediate_output)\n",
    "print(intermediate_output.shape)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Model Definition:"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 11,
   "metadata": {
    "colab": {
     "autoexec": {
      "startup": false,
      "wait_interval": 0
     },
     "base_uri": "https://localhost:8080/",
     "height": 748,
     "output_extras": [
      {
       "item_id": 1
      }
     ]
    },
    "colab_type": "code",
    "executionInfo": {
     "elapsed": 1754,
     "status": "ok",
     "timestamp": 1521576825171,
     "user": {
      "displayName": "Malavika Bindhi",
      "photoUrl": "https://lh3.googleusercontent.com/a/default-user=s128",
      "userId": "112270139007359607953"
     },
     "user_tz": 420
    },
    "id": "jcT9YQlSA4Po",
    "outputId": "a7f5f681-43e8-407d-d97c-850f0ba4c0a9"
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "__________________________________________________________________________________________________\n",
      "Layer (type)                    Output Shape         Param #     Connected to                     \n",
      "==================================================================================================\n",
      "input_1 (InputLayer)            (None, 2048, 3)      0                                            \n",
      "__________________________________________________________________________________________________\n",
      "lambda_1 (Lambda)               (None, 2048, 3)      0           input_1[0][0]                    \n",
      "__________________________________________________________________________________________________\n",
      "conv1d_4 (Conv1D)               (None, 2048, 64)     256         lambda_1[0][0]                   \n",
      "__________________________________________________________________________________________________\n",
      "conv1d_5 (Conv1D)               (None, 2048, 64)     4160        conv1d_4[0][0]                   \n",
      "__________________________________________________________________________________________________\n",
      "lambda_2 (Lambda)               (None, 2048, 64)     0           conv1d_5[0][0]                   \n",
      "__________________________________________________________________________________________________\n",
      "conv1d_9 (Conv1D)               (None, 2048, 64)     4160        lambda_2[0][0]                   \n",
      "__________________________________________________________________________________________________\n",
      "conv1d_10 (Conv1D)              (None, 2048, 128)    8320        conv1d_9[0][0]                   \n",
      "__________________________________________________________________________________________________\n",
      "conv1d_11 (Conv1D)              (None, 2048, 1024)   132096      conv1d_10[0][0]                  \n",
      "__________________________________________________________________________________________________\n",
      "max_pooling1d_3 (MaxPooling1D)  (None, 1, 1024)      0           conv1d_11[0][0]                  \n",
      "__________________________________________________________________________________________________\n",
      "flatten_1 (Flatten)             (None, 1024)         0           max_pooling1d_3[0][0]            \n",
      "__________________________________________________________________________________________________\n",
      "intermediate_output (InputLayer (None, 2048)         0                                            \n",
      "__________________________________________________________________________________________________\n",
      "concatenate_1 (Concatenate)     (None, 3072)         0           flatten_1[0][0]                  \n",
      "                                                                 intermediate_output[0][0]        \n",
      "__________________________________________________________________________________________________\n",
      "dense_7 (Dense)                 (None, 512)          1573376     concatenate_1[0][0]              \n",
      "__________________________________________________________________________________________________\n",
      "dense_8 (Dense)                 (None, 128)          65664       dense_7[0][0]                    \n",
      "__________________________________________________________________________________________________\n",
      "dense_9 (Dense)                 (None, 128)          16512       dense_8[0][0]                    \n",
      "__________________________________________________________________________________________________\n",
      "dense_10 (Dense)                (None, 24)           3096        dense_9[0][0]                    \n",
      "__________________________________________________________________________________________________\n",
      "dense_11 (Dense)                (None, 3)            387         dense_9[0][0]                    \n",
      "==================================================================================================\n",
      "Total params: 1,808,027\n",
      "Trainable params: 1,808,027\n",
      "Non-trainable params: 0\n",
      "__________________________________________________________________________________________________\n",
      "None\n"
     ]
    }
   ],
   "source": [
    "\n",
    "def mat_mul(A, B):\n",
    "    return tf.matmul(A, B)\n",
    "\n",
    "# number of points in each sample\n",
    "num_points = 2048\n",
    "\n",
    "# number of categories\n",
    "k = 3\n",
    "\n",
    "# define optimizer\n",
    "adam = optimizers.Adam(lr=0.001, decay=0.7)\n",
    "\n",
    "# ------------------------------------ Pointnet Architecture\n",
    "# input_Transformation_net\n",
    "input_points = Input(shape=(num_points, 3))\n",
    "x = Convolution1D(64, 1, activation='relu',\n",
    "                  input_shape=(num_points, 3))(input_points)\n",
    "#x = BatchNormalization()(x)\n",
    "x = Convolution1D(128, 1, activation='relu')(x)\n",
    "#x = BatchNormalization()(x)\n",
    "x = Convolution1D(1024, 1, activation='relu')(x)\n",
    "#x = BatchNormalization()(x)\n",
    "x = MaxPooling1D(pool_size=num_points)(x)\n",
    "x = Dense(512, activation='relu')(x)\n",
    "#x = BatchNormalization()(x)\n",
    "x = Dense(256, activation='relu')(x)\n",
    "#x = BatchNormalization()(x)\n",
    "x = Dense(9, weights=[np.zeros([256, 9]), np.array([1, 0, 0, 0, 1, 0, 0, 0, 1]).astype(np.float32)])(x)\n",
    "input_T = Reshape((3, 3))(x)\n",
    "\n",
    "# forward net\n",
    "g = Lambda(mat_mul, arguments={'B': input_T})(input_points)\n",
    "g = Convolution1D(64, 1, input_shape=(num_points, 3), activation='relu')(g)\n",
    "#g = BatchNormalization()(g)\n",
    "g = Convolution1D(64, 1, input_shape=(num_points, 3), activation='relu')(g)\n",
    "#g = BatchNormalization()(g)\n",
    "\n",
    "# feature transform net\n",
    "f = Convolution1D(64, 1, activation='relu')(g)\n",
    "#f = BatchNormalization()(f)\n",
    "f = Convolution1D(128, 1, activation='relu')(f)\n",
    "#f = BatchNormalization()(f)\n",
    "f = Convolution1D(1024, 1, activation='relu')(f)\n",
    "#f = BatchNormalization()(f)\n",
    "f = MaxPooling1D(pool_size=num_points)(f)\n",
    "f = Dense(512, activation='relu')(f)\n",
    "#f = BatchNormalization()(f)\n",
    "f = Dense(256, activation='relu')(f)\n",
    "#f = BatchNormalization()(f)\n",
    "f = Dense(64 * 64, weights=[np.zeros([256, 64 * 64]), np.eye(64).flatten().astype(np.float32)])(f)\n",
    "feature_T = Reshape((64, 64))(f)\n",
    "\n",
    "# forward net\n",
    "g = Lambda(mat_mul, arguments={'B': feature_T})(g)\n",
    "g = Convolution1D(64, 1, activation='relu')(g)\n",
    "#g = BatchNormalization()(g)\n",
    "g = Convolution1D(128, 1, activation='relu')(g)\n",
    "#g = BatchNormalization()(g)\n",
    "g = Convolution1D(1024, 1, activation='relu')(g)\n",
    "#g = BatchNormalization()(g)\n",
    "\n",
    "# global_feature\n",
    "global_feature = MaxPooling1D(pool_size=num_points)(g)\n",
    "global_feature = Flatten()(global_feature)\n",
    "# point_net_cls\n",
    "#c = Dense(512, activation='relu')(global_feature)\n",
    "#c = BatchNormalization()(c)\n",
    "#c = Dropout(rate=0.7)(c)\n",
    "#c = Dense(256, activation='relu')(c)\n",
    "#c = BatchNormalization()(c)\n",
    "#c = Dropout(rate=0.7)(c)\n",
    "#c = Dense(k, activation='softmax')(c)\n",
    "#prediction = Flatten()(c)\n",
    "# --------------------------------------------------end of pointnet\n",
    "\n",
    "#Fusion\n",
    "\n",
    "resnet_activation = Input(shape=(intermediate_output.shape[1],), name='intermediate_output')\n",
    "f = Concatenate()([global_feature, resnet_activation])\n",
    "\n",
    "#Definition of MLP Layer\n",
    "f = Dense(512, activation='relu')(f)\n",
    "f = Dense(128, activation='relu')(f)\n",
    "f = Dense(128, activation='relu')(f)\n",
    "boxes = Dense(labels.shape[-1])(f)\n",
    "classes = Dense(classes.shape[-1])(f)\n",
    "\n",
    "\n",
    "# print the model summary\n",
    "model = Model(inputs=[input_points, resnet_activation], outputs=[boxes, classes])\n",
    "print(model.summary())\n"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Load Data:"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 15,
   "metadata": {
    "colab": {
     "autoexec": {
      "startup": false,
      "wait_interval": 0
     },
     "base_uri": "https://localhost:8080/",
     "height": 221,
     "output_extras": [
      {
       "item_id": 1
      }
     ]
    },
    "colab_type": "code",
    "executionInfo": {
     "elapsed": 326,
     "status": "ok",
     "timestamp": 1521576840328,
     "user": {
      "displayName": "Malavika Bindhi",
      "photoUrl": "https://lh3.googleusercontent.com/a/default-user=s128",
      "userId": "112270139007359607953"
     },
     "user_tz": 420
    },
    "id": "Sgj7I88gBf6_",
    "outputId": "39b71cde-0bb3-4d53-c4ed-c9022626460e"
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "(6750, 2048, 3)\n",
      "(6750, 24)\n",
      "(6750, 3)\n",
      "(6750, 2048)\n",
      "(365, 2048, 3)\n",
      "(365, 24)\n",
      "(365, 3)\n",
      "(365, 2048)\n",
      "(366, 2048, 3)\n",
      "(366, 24)\n",
      "(366, 3)\n",
      "(366, 2048)\n"
     ]
    }
   ],
   "source": [
    "index = np.load('permuted_indices.npy')\n",
    "\n",
    "train_points = points[index[0:6750]]\n",
    "dev_points = points[index[6750:7115]]\n",
    "test_points = points[index[7115:]]\n",
    "\n",
    "train_classes = classes[index[0:6750]]\n",
    "dev_classes = classes[index[6750:7115]]\n",
    "test_classes = classes[index[7115:]]\n",
    "\n",
    "train_labels = labels[index[0:6750]]\n",
    "dev_labels = labels[index[6750:7115]]\n",
    "test_labels = labels[index[7115:]]\n",
    "\n",
    "train_intermediate = intermediate_output[index[0:6750]]\n",
    "dev_intermediate = intermediate_output[index[6750:7115]]\n",
    "test_intermediate = intermediate_output[index[7115:]]\n",
    "\n",
    "print(train_points.shape)\n",
    "print(train_labels.shape)\n",
    "print(train_classes.shape)\n",
    "print(train_intermediate.shape)\n",
    "\n",
    "print(dev_points.shape)\n",
    "print(dev_labels.shape)\n",
    "print(dev_classes.shape)\n",
    "print(dev_intermediate.shape)\n",
    "\n",
    "print(test_points.shape)\n",
    "print(test_labels.shape)\n",
    "print(test_classes.shape)\n",
    "print(test_intermediate.shape)"
   ]
  },
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "Training:"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {
    "colab": {
     "autoexec": {
      "startup": false,
      "wait_interval": 0
     },
     "base_uri": "https://localhost:8080/",
     "height": 1091,
     "output_extras": [
      {
       "item_id": 196
      },
      {
       "item_id": 456
      },
      {
       "item_id": 677
      },
      {
       "item_id": 738
      },
      {
       "item_id": 825
      },
      {
       "item_id": 915
      },
      {
       "item_id": 1039
      },
      {
       "item_id": 1169
      },
      {
       "item_id": 1232
      },
      {
       "item_id": 1322
      },
      {
       "item_id": 1430
      },
      {
       "item_id": 1495
      },
      {
       "item_id": 1582
      },
      {
       "item_id": 1643
      },
      {
       "item_id": 1730
      },
      {
       "item_id": 1836
      },
      {
       "item_id": 1925
      },
      {
       "item_id": 2013
      },
      {
       "item_id": 2074
      },
      {
       "item_id": 2112
      }
     ]
    },
    "colab_type": "code",
    "collapsed": true,
    "executionInfo": {
     "elapsed": 1510871,
     "status": "ok",
     "timestamp": 1521578355065,
     "user": {
      "displayName": "Malavika Bindhi",
      "photoUrl": "https://lh3.googleusercontent.com/a/default-user=s128",
      "userId": "112270139007359607953"
     },
     "user_tz": 420
    },
    "id": "ol7vT41PBkUF",
    "outputId": "fd246b26-46f3-4bbe-d1cc-347dcd044f86"
   },
   "outputs": [],
   "source": [
    "HUBER_DELTA = 0.5\n",
    "def smoothL1(y_true, y_pred):\n",
    "   x   = K.abs(y_true - y_pred)\n",
    "   x   = K.switch(x < HUBER_DELTA, 0.5 * x ** 2, HUBER_DELTA * (x - 0.5 * HUBER_DELTA))\n",
    "   return  K.sum(x)\n",
    "  \n",
    "  \n",
    "#epoch number\n",
    "epo = 450\n",
    "# define optimizer\n",
    "adam = optimizers.Adam(lr=0.001, decay=0.7)\n",
    "# compile classification model\n",
    "model.compile(optimizer='adam',\n",
    "              loss=[smoothL1, 'mean_squared_error'],\n",
    "              metrics=['accuracy'])\n",
    "\n",
    "history = model.fit(x = [train_points, train_intermediate], y= [train_labels, train_classes], batch_size=32, epochs=epo, validation_data=([dev_points,dev_intermediate], [dev_labels, dev_classes]), shuffle=True, verbose=1)\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 0,
   "metadata": {
    "colab": {
     "autoexec": {
      "startup": false,
      "wait_interval": 0
     }
    },
    "colab_type": "code",
    "collapsed": true,
    "id": "pyathnROB7ib"
   },
   "outputs": [],
   "source": [
    "#model.save('/drive/Colab Notebook/current_model')\n",
    "import pickle\n",
    "\n",
    "with open('drive/Colab Notebooks/trainHistoryDict_history450', 'wb') as file_pi:\n",
    "     pickle.dump(history.history, file_pi)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 0,
   "metadata": {
    "colab": {
     "autoexec": {
      "startup": false,
      "wait_interval": 0
     }
    },
    "colab_type": "code",
    "collapsed": true,
    "id": "HWwRJbvdKI18"
   },
   "outputs": [],
   "source": [
    "model.save_weights('drive/Colab Notebooks/my_model_weights_450.h5')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 31,
   "metadata": {
    "colab": {
     "autoexec": {
      "startup": false,
      "wait_interval": 0
     },
     "base_uri": "https://localhost:8080/",
     "height": 34,
     "output_extras": [
      {
       "item_id": 1
      }
     ]
    },
    "colab_type": "code",
    "executionInfo": {
     "elapsed": 1312,
     "status": "ok",
     "timestamp": 1521591872152,
     "user": {
      "displayName": "Malavika Bindhi",
      "photoUrl": "https://lh3.googleusercontent.com/a/default-user=s128",
      "userId": "112270139007359607953"
     },
     "user_tz": 420
    },
    "id": "NTrB3Dvf8USk",
    "outputId": "130820dc-d39a-4d20-8a85-118f1c7bdc5f"
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Test Loss: [164.50030288279382, 164.4655409015593, 0.034760263916410385, 0.3852459018021985, 0.9562841520283392]\n"
     ]
    }
   ],
   "source": [
    "# Evaluating the model on the test data    \n",
    "loss = model.evaluate([test_points, test_intermediate], [test_labels, test_classes], verbose=0)\n",
    "print('Test Loss:', loss)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 44,
   "metadata": {
    "colab": {
     "autoexec": {
      "startup": false,
      "wait_interval": 0
     },
     "base_uri": "https://localhost:8080/",
     "height": 34,
     "output_extras": [
      {
       "item_id": 1
      }
     ]
    },
    "colab_type": "code",
    "executionInfo": {
     "elapsed": 1257,
     "status": "ok",
     "timestamp": 1521605382670,
     "user": {
      "displayName": "Malavika Bindhi",
      "photoUrl": "https://lh3.googleusercontent.com/a/default-user=s128",
      "userId": "112270139007359607953"
     },
     "user_tz": 420
    },
    "id": "o0xopLNDeePq",
    "outputId": "5dbdfe14-3978-4719-de42-aa9ce8a03dbd"
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "Dev Loss: [144.130226741425, 144.10207822616786, 0.028150066447584596, 0.37534246656992665, 0.9616438359430391]\n"
     ]
    }
   ],
   "source": [
    "#Evaluating model of Dev Set\n",
    "loss = model.evaluate([dev_points, dev_intermediate], [dev_labels, dev_classes], verbose=0)\n",
    "print('Dev Loss:', loss)"
   ]
  }
 ],
 "metadata": {
  "accelerator": "GPU",
  "colab": {
   "default_view": {},
   "name": "PointFusion_repeat_training.ipynb",
   "provenance": [],
   "version": "0.3.2",
   "views": {}
  },
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.6.2"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 1
}
